I have a variable that store Date in Generic value. and now i want to format the variable in this format yyyy/MM/dd instead of dd/MM/yyyy.
eg: strAppDate in Generic Value store Date (09/03/2022)
when i run the script, i keep hit error “Cannot convert Generic Value to System.Date.Time”
Do i need to change type of variable for strAppDate?
jack.chan
(Jack Chan)
2
try this
dateTime.ParseExact(genericVal.ToString, "dd/MM/yyyy",nothing).ToString("yyyy/MM/dd")
but where can i put this variable strAppDate. since this variable store the value that need to be format
jack.chan
(Jack Chan)
5
@user123mem do this
strAppDate = new genericValue(dateTime.ParseExact(strAppDate.ToString, "dd/MM/yyyy",nothing).ToString("yyyy/MM/dd"))
postwick
(Paul)
7
The real question is why are you using a Generic Value variable?
i read some of the forum here, they using Generic value variable , so i just give it a try
postwick
(Paul)
9
It’s much better to be specific about your datatypes. I’ve never had any reason to use Generic Value.
1 Like
You could also try
CDate(YourVariable).ToString(“Format you want”)
system
(system)
Closed
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.