|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
hi there i a slight problem i have a field which accepts the date as dd/mm/yyyy but when i insert the value it becomes mm/dd/yyyy for some date values like 9 april become 4 august.... the database date format is mm/dd/yyyy and i just take the value out and display it as dd/mm/yyyy.. however ... my update and inserts can't use the same function, cos the function is just display out the server's date as dd/mm/yyyy... how should i add i in correctly?
Code:
Dim ddate, ydate, mdate Function FormatDateDM2MD(sdate) if sdate="" or sdate=" " then FormatDateDM2MD = "NULL" else ddate=day(sdate) mdate=month(sdate) ydate=year(sdate) sdate= ydate & "/" & mdate & "/" & ddate FormatDateDM2MD = "'"&sdate&"'" end if End Function hi again i have another problem my date values when its 10 of Nov it comes out as 11/10/2003 instead of 10/11/2003 why? how do i solve it? here's my function Code:
Function FormatMediumDate(DateValue)
Dim strYYYY
Dim strMM
Dim strDD
strYYYY = CStr(DatePart("yyyy", DateValue))
strMM = CStr(DatePart("m", DateValue))
If Len(strMM) = 1 Then strMM = "0" & strMM
strDD = CStr(DatePart("d", DateValue))
If Len(strDD) = 1 Then strDD = "0" & strDD
FormatMediumDate = strDD & "/" & strMM & "/" & strYYYY
End Function
the date is generated by a pop up calender.. u can view it here www14.brinkster.com/siewhua/addPage.asp Last edited by icepricessa : October 17th, 2003 at 09:27 PM. |
|
#2
|
|||
|
|||
|
THe function works fine, you're probably just coding something incorrectly, i'd look at how you're using the function
|
|
#3
|
||||
|
||||
|
foe example?
|
|
#4
|
|||
|
|||
|
Do you know how functions work? Think of it like a variable, treat it the same way ex;
Code:
response.write FormatDateDM2MD(sdate) or dim blah blah = FormatDateDM2MD(sdate) gives you the value you're looking for PS happy 666 posts for me |
|
#5
|
|||
|
|||
|
or u can try this popup date that can be customised to dd/mm/yyyy or mm/dd/yyyy.
http://www.dynamicdrive.com/dynamic...opcalendar2.htm
__________________
Hope this helps. Mike Royal Selangor Pewter "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > inserting a date value into sql server (urgent!!) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|