Solved

Univ format for date: aaaammgg hh:mm:ss

Posted on 2002-04-02
7
550 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now