Solved

Univ format for date: aaaammgg hh:mm:ss

Posted on 2002-04-02
7
557 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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