Solved

Univ format for date: aaaammgg hh:mm:ss

Posted on 2002-04-02
7
559 Views
Last Modified: 2008-02-26
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
Comment
Question by:getronick
7 Comments
 
LVL 7

Expert Comment

by:John844
ID: 6913574
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
 
LVL 20

Expert Comment

by:Silvers5
ID: 6913575
MyDate = Year(Now) & "/" & Month(Now) & "/" & Day(Now) & " " & Time

instead of now you can put your date..


or also you can use formatdatetime function

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

Accepted Solution

by:
thunderchicken earned 120 total points
ID: 6913576
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 6

Expert Comment

by:ebosscher
ID: 6913845
umm.. this may seem overly simplistic, but why not use the DateTimeFormat("string", vbLongDate)?
0
 
LVL 7

Expert Comment

by:John844
ID: 6913967
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
 
LVL 6

Expert Comment

by:ebosscher
ID: 6913974
wow.. I was way out.. thanks John844.. my bad
0
 
LVL 7

Expert Comment

by:John844
ID: 6925882
are you still needing more info getronick???
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in query expression 3 54
Hide Table in merge 3 42
ASP AND XML 3 31
Replace value 2 35
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question