[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Coverting Date Format mm/dd/yy to yyyy-mm-dd To Insert into MySQL

Posted on 2006-06-07
4
Medium Priority
?
516 Views
Last Modified: 2007-12-19
I recently got some help converting Dates to display as yyyy-mm-dd to keep consistent with the MySQL format.  Unfortunately I now need to reverse that it so the Dates display as the default mm/dd/yy, but convert when the form is submitted to yyyy-mm-dd for proper insertion into the database.  If someone could offerhelp with that code I would appreciate it.  Thanks.
0
Comment
Question by:blob150
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16853752
If you cannot use the FormatDate function consider something like this function:

Function Date2YMD (ByVal Dat)

Date2YMD = CStr(Year(Dat)) & "-" & Right("0" & CStr(Month(Dat)), 2) "-" & Right("0" & CStr(Day(Dat)), 2)

End Function
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16853765
Oops, typo:

Function Date2YMD (ByVal Dat)

Date2YMD = CStr(Year(Dat)) & "-" & Right("0" & CStr(Month(Dat)), 2) & "-" & Right("0" & CStr(Day(Dat)), 2)

End Function
0
 

Author Comment

by:blob150
ID: 16856290
Thanks for the reply.  I can get the function to display the dates as yyyy-mm-dd when the page loads, but I need the dates to display as mm/dd/yy and convert to yyyy-mm-dd only after the form is submitted.  How can I do that?
0
 
LVL 31

Accepted Solution

by:
alorentz earned 150 total points
ID: 16856422
You just store each format in 2 different variables.  ONe variable has one format....the other variable has the other format.  Then use them as you need them.

You have all the information you need for your previous questions...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

834 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