Quick Search for:  in language:    
these,couple,functions,written,because,strugg
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 203,988. lines
 Jobs: 110. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login


 

 


Latest Code Ticker for ASP/ VbScript
aZoaPeS
By Simeon Albertson on 1/20


Move Window , Funs Stuff
By Jareh Ali Mohamed H. Al-Malki on 1/19


Click here to see a screenshot of this code!Rapid Classified v2.0
By Gurgen Alaverdian on 1/17

(Screen Shot)

Click here to see a screenshot of this code!Gallery Image with Zoom
By Marcelo Valle Franco on 1/12

(Screen Shot)

Click here to see a screenshot of this code!ASP Photo Competition
By Saul Bryan on 1/12

(Screen Shot)

Execute DTS package
By Himadrish Laha on 1/12


Connecting to a MySQL with ADO, DAO and RDO
By Ahmed Magdy Ezzeldin on 1/11


Automatic Form Insertion To Database
By Yasar Bayar on 1/11


Click here to see a screenshot of this code!Find Closest Physical Location (based on zip code, etc)
By Mark Kahn on 1/11

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

mySQL datein-dateout

Print
Email
 
VB icon
Submitted on: 11/24/2003 7:04:29 PM
By: thorpe hepburn  
Level: Beginner
User Rating: Unrated
Compatibility:ASP (Active Server Pages)

Users have accessed this code 639 times.
 
(About the author)
 
     these are a couple of functions ive written because i struggled for a while with getting dates and times into and out of a mySQL db. there probably a bit long winded but they work.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: mySQL datein-dateout
    ' Description:these are a couple of func
    '     tions ive written because i struggled fo
    '     r a while with getting dates and times i
    '     nto and out of a mySQL db.
    there probably a bit Long winded but they work.
    ' By: thorpe hepburn
    '
    ' Inputs:
    mysql_datein(now) = YYYY/MM/DD 18:11:22
    '
    ' Returns:
    mysql_dateout(now) = DD/MM/YY 06:11 PM
    '
    ' Assumes:the mysql_dateout is in aus fo
    '     rmat. DD/MM/YY, but you can change the o
    '     rder to what ever you like.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=8637&lngWId;=4    'for details.    '**************************************
    
    	function mysql_datein(var)
    		Dim formed_year, formed_month, formed_day, formed_hour, formed_minute, formed_second
    		formed_year = datepart("yyyy", var)
    		formed_month = datepart("m", var)
    		formed_day = datepart("d", var)
    		formed_hour = datepart("h",var)
    		formed_minute = datepart("n", var)
    		formed_second = datepart("s", var)
    		if len(formed_month) < 2 Then
    			formed_month = "0" & formed_month
    		Else
    			formed_month = formed_month
    		End if
    		if len(formed_day) < 2 Then
    			formed_day = "0" & formed_day
    		Else
    			formed_day = formed_day
    		End if
    		if len(formed_hour) < 2 Then
    			formed_hour = "0" & formed_hour
    		Else
    			formed_hour = formed_hour
    		End if
    		if len(formed_minute) < 2 Then
    			formed_minute = "0" & formed_minute
    		Else
    			formed_minute = formed_minute
    		End if
    		if len(formed_second) < 2 Then
    			formed_second = "0" & formed_second
    		Else
    			formed_second = formed_second
    		End if
    		temp = formed_year & "/" & formed_month & "/" & formed_day & " " & formed_hour & ":" & formed_minute & ":" & formed_second
    		mysql_datein = temp
    	End function
    	function mysql_dateout(var)
    		Dim formed_year, formed_month, formed_day, formed_hour, formed_minute, formed_second
    		formed_year = right(datepart("yyyy", var), 2)
    		formed_month = datepart("m", var)
    		formed_day = datepart("d", var)
    		formed_hour = datepart("h", var)
    		if formed_hour < 13 Then
    			x = " AM"
    		Else
    			x = " PM"
    		End if
    		formed_hour = datepart("h", var) mod 12
    		formed_minute = datepart("n", var)
    		formed_second = datepart("s", var)
    		if len(formed_month) < 2 Then
    			formed_month = "0" & formed_month
    		Else
    			formed_month = formed_month
    		End if
    		if len(formed_day) < 2 Then
    			formed_day = "0" & formed_day
    		Else
    			formed_day = formed_day
    		End if
    		if len(formed_hour) < 2 Then
    			formed_hour = "0" & formed_hour
    		Else
    			formed_hour = formed_hour
    		End if
    		if len(formed_minute) < 2 Then
    			formed_minute = "0" & formed_minute
    		Else
    			formed_minute = formed_minute
    		End if
    		if len(formed_second) < 2 Then
    			formed_second = "0" & formed_second
    		Else
    			formed_second = formed_second
    		End if
    		temp = formed_day & "/" & formed_month & "/" & formed_year & " " & formed_hour & ":" & formed_minute & ":" & formed_second & x
    		mysql_dateout = temp
    	End function


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.