• Status: Solved
• Priority: Medium
• Security: Public
• Views: 580

# Univ format for date: aaaammgg hh:mm:ss

Kind all,
does anybody can kinldy indicate to me how can I format date in a way I can insert them into the DB in the
univ. format for date: aaaammgg hh:mm:ss

Tnx n regards

D
0
getronick
1 Solution

Commented:
I am not sure what aaaammgg is, but I will guess aaaa is the year with century and gg is the day

dim strNewValue
dim datDate

datDate = now()

strNewValue = year(datDate) & right("0" & month(datDate),2) & right("0" & day(datDate),2) & " " & right("0" & hour(datDate),2) & ":" & right("0" & minute(datDate),2) & ":" & right("0" & second(datDate),2)

response.write "New value to store = " & strNewValue

John
0

Commented:
MyDate = Year(Now) & "/" & Month(Now) & "/" & Day(Now) & " " & Time

or also you can use formatdatetime function

MyDate = FormatDateTime(Now,1)   .. test it from 0 to 4 i guess..
0

Commented:
ugly, but it will work

dim strTemp, yourdate
strTemp = ""
yourdate = now()
strTemp = strTemp & year(yourdate)
if len(month(yourdate)) = 1 then
strTemp = strTemp & "0" & month(yourdate)
else
strTemp = strTemp & month(yourdate)
end if
if len(day(yourdate)) = 1 then
strTemp = strTemp & "0" & day(yourdate)
else
strTemp = strTemp & day(yourdate)
end if
if len(hour(yourdate)) = 1 then
strTemp = strTemp & "  0" & hour(yourdate)
else
strTemp = strTemp & "  " & hour(yourdate)
end if
if len(minute(yourdate)) = 1 then
strTemp = strTemp & "0" & minute(yourdate)
else
strTemp = strTemp & "  " & minute(yourdate)
end if
if len(second(yourdate)) = 1 then
strTemp = strTemp & "0" & second(yourdate)
else
strTemp = strTemp & second(yourdate)
end if

response.write strTemp

0

Commented:
umm.. this may seem overly simplistic, but why not use the DateTimeFormat("string", vbLongDate)?
0

Commented:
obosscher,
FYI, DateTimeFormat does not exist.  FormatDateTime does exist, but still does not return the requested date format.  FormatDateTime(Now(),vbLongDate) returns "Tuesday, April 02, 2002"
0

Commented:
wow.. I was way out.. thanks John844.. my bad
0

Commented: