Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date Format needs adjustment
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hello All,

My objective is to select date in the past, format it to dd.mm.yyyy format and input into field which validates only dates in this format. What I was able to produce so far is:

Code:
Dim TestDate
TestDate = DateAdd("d", -65, Date)

This code produces date in yyyy-mm-dd format. I have checked FormatDateTime function and there is no option to format date according to format that I require (dd.mm.yyyy). Since I have found no other VBScript functions which format dates I am asking whether you have encountered such situation and have some working solution?
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Alert cancelled Smile , solution is as follows:

Code:
Dim TestDate, RUDDate
TestDate = DateAdd("d", -65, Date)

Date1 = Datepart("d",TestDate)
month1 = Datepart("m",TestDate)
year1 = Datepart("yyyy",TestDate)

If len(Date1) = 1 then
Date1 = "0" & Date1
Else
Date1 = Date1
End If

If len(month1) = 1 then
month1 = "0" & month1
Else
month1 = month1
End If

RUDDate = month1 & "." & Date1 & "." & year1
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi ,

Try in the below way Smile

Code:
Dim TestDate
  TestDate = DateAdd("d", -65, Date)
  dpart=datepart("d",TestDate)
  mpart=datepart("m",TestDate)
  ypart=datepart("yyyy",TestDate)
  
  Final_TestDate=dpart&"."&mpart&"."&ypart
  msgbox Final_TestDate
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to change 24 hrs time format to 12 hrs time format Varsha Gupta 1 2,814 04-21-2018, 11:06 AM
Last Post: Ankur
  How to validate a format of an alphanumeric string PrateepKaraval 2 5,986 11-08-2014, 10:26 AM
Last Post: vinod123
  How to validate date in an application should not accept less than future date. ruchi03 1 3,636 10-08-2014, 05:54 PM
Last Post: rajkumarsm
  Date Picker Issue - Unable to select date link dynamically rajkumarsm 1 5,164 09-20-2014, 09:31 AM
Last Post: rajkumarsm
  Pdf to Excel or any other Format Conversion branjitk 1 2,468 06-14-2012, 08:14 AM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)