Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: date-functions


Message #1 by "Wit B." <B.Wit@g...> on Wed, 20 Dec 2000 11:36:40 +0100
Hello



Recently I saw a few comments about several date-functions. A coworker has a

problem with sending dates to a SQL database. He converts the date using

cdate(), but that sometimes doesn't work out. It puts 1 march 2000

(01-03-2000) in as 3 january (03-01-2000) and so, but 15-12-2000 stays that

way.



Does anyone know what to do or what function to use to get this right??



Thanx already



grt Bas Wit



www.atosorigin.com





---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 20 Dec 2000 12:44:02 +0100
Hi Bas,



One way to solve this is to feed the yyyy/mm/dd format to the database. 

Build your own function to create this date:



function myDate(sDate)

         myDate = year(sDate) & "/" month(sDate) & "/" & day(sDate)

end function



As far as I know, all regional settings (Dutch, English etc) will interpret 

this as a correct date.



HtH



Imar





At 11:36 AM 12/20/2000 +0100, you wrote:

>Hello

>

>Recently I saw a few comments about several date-functions. A coworker has a

>problem with sending dates to a SQL database. He converts the date using

>cdate(), but that sometimes doesn't work out. It puts 1 march 2000

>(01-03-2000) in as 3 january (03-01-2000) and so, but 15-12-2000 stays that

>way.

>

>Does anyone know what to do or what function to use to get this right??

>

>Thanx already

>

>grt Bas Wit

>

>www.atosorigin.com

>

>

>---









---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #3 by Gregory_Griffiths@c... on Wed, 20 Dec 2000 11:18:05 +0000
If you are using Oracle, check out the TO_DATE and the TO_STRING 

operators, if you are using MySQL try DATE_FORMAT, other databases I 

expect have similar functions.



> -----Original Message-----

> From: B.Wit@g... [mailto:B.Wit@g...]

> Sent: 20 December 2000 10:37

> To: asp_web_howto@p...

> Cc: B.Wit@g...

> Subject: [asp_web_howto] date-functions

> 

> 

> Hello

> 

> Recently I saw a few comments about several date-functions. A 

> coworker has a

> problem with sending dates to a SQL database. He converts the 

> date using

> cdate(), but that sometimes doesn't work out. It puts 1 march 2000

> (01-03-2000) in as 3 january (03-01-2000) and so, but 

> 15-12-2000 stays that

> way.

> 

> Does anyone know what to do or what function to use to get 

> this right??

> 

> Thanx already

> 

> grt Bas Wit

> 

> www.atosorigin.com

> 

> 







---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #4 by "Morgan, Rob" <Rob.Morgan@o...> on Wed, 20 Dec 2000 07:33:31 -0500
Here is my code for dealing with Oracle datetime fields.



 	if dob <> "" then

		checkdob = isDate(dob)

		if checkdob = false then

			error = error & "<li> Date of Birth is not a valid

date <br>"

		else

			dob = dateformat(dob)

		end if

	end if





function timeformat(ftime)

	ftime = FormatDateTime(ftime,4)

	oktime = datepart("h",ftime) & " " & datepart("n", ftime) & " " &

datepart("s", ftime)

	ftime = FormatDateTime(ftime,0)

	timeformat = oktime

end function



function dateformat(fdate)

	Dim datemonth

	fdate = FormatDateTime(fdate,0)

	select case datepart("m",fdate)

		case "1"

			datemonth = "Jan"

		case "2"

			datemonth = "Feb"

		case "3"

			datemonth = "Mar"

		case "4"

			datemonth = "Apr"

		case "5"

			datemonth = "May"

		case "6"

			datemonth = "Jun"

		case "7"

			datemonth = "Jul"

		case "8"

			datemonth = "Aug"

		case "9"

			datemonth = "Sep"

		case "10"

			datemonth = "Oct"

		case "11"

			datemonth = "Nov"

		case "12"

			datemonth = "Dec"

	end select

	

	fdate = datepart("yyyy",fdate) & "-" & datemonth & "-" &

datepart("d", fdate) 

	dateformat = trim(fdate)

end function			



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Wednesday, December 20, 2000 6:18 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: date-functions





If you are using Oracle, check out the TO_DATE and the TO_STRING 

operators, if you are using MySQL try DATE_FORMAT, other databases I 

expect have similar functions.



> -----Original Message-----

> From: B.Wit@g... [mailto:B.Wit@g...]

> Sent: 20 December 2000 10:37

> To: asp_web_howto@p...

> Cc: B.Wit@g...

> Subject: [asp_web_howto] date-functions

> 

> 

> Hello

> 

> Recently I saw a few comments about several date-functions. A 

> coworker has a

> problem with sending dates to a SQL database. He converts the 

> date using

> cdate(), but that sometimes doesn't work out. It puts 1 march 2000

> (01-03-2000) in as 3 january (03-01-2000) and so, but 

> 15-12-2000 stays that

> way.

> 

> Does anyone know what to do or what function to use to get 

> this right??

> 

> Thanx already

> 

> grt Bas Wit

> 

> www.atosorigin.com

> 

> 









---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #5 by "Unterste, Andreas" <unterste@d...> on Wed, 20 Dec 2000 07:10:42 -0600
I definetly recommend this as well - I'm not using any CDate() etc. anymore

just to find out that there's yet another regional setting environment in

which I shuffle the wrong date to my database. YYYYMMDD appears in SQL

server always to be safe bet no matter what settings applied.



Cheers,

Andreas



Andreas





-----Original Message-----

From: Imar Spaanjaars [mailto:Imar@S...]

Sent: Wednesday, December 20, 2000 12:44

To: ASP Web HowTo

Subject: [asp_web_howto] Re: date-functions





Hi Bas,



One way to solve this is to feed the yyyy/mm/dd format to the database. 

Build your own function to create this date:



function myDate(sDate)

         myDate = year(sDate) & "/" month(sDate) & "/" & day(sDate)

end function



As far as I know, all regional settings (Dutch, English etc) will interpret 

this as a correct date.



HtH



Imar





At 11:36 AM 12/20/2000 +0100, you wrote:

>Hello

>

>Recently I saw a few comments about several date-functions. A coworker has

a

>problem with sending dates to a SQL database. He converts the date using

>cdate(), but that sometimes doesn't work out. It puts 1 march 2000

>(01-03-2000) in as 3 january (03-01-2000) and so, but 15-12-2000 stays that

>way.

>

>Does anyone know what to do or what function to use to get this right??

>

>Thanx already

>

>grt Bas Wit

>

>www.atosorigin.com

>

>

>---









---



---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #6 by Ron Newsham <rnewsham@t...> on Wed, 20 Dec 2000 16:14:21 +0000
>===== Original Message From "Morgan, Rob" <Rob.Morgan@o...> =====

Here is a fragment of T-SQL that converts a date into a safe date string... 

you can use the same method for VB[script] code...



set @sDate = cast(day( @Date ) as varchar(2) ) + '/' + 

substring('JanFebMarAprMayJunJulAugSepOctNovDec',1+3*(month(@Date)-1),3) + '/' 

+cast( Year(@Date) as varchar(4))



---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #7 by "Ken Schaefer" <ken@a...> on Thu, 21 Dec 2000 13:14:22 +1100
You need to change the settings on the server to get this correct.



15-12-2000 can only be interpreted one way, ie 15th December - it can't be

intepreted as the 12th day of the 15th month.



If you're on NT, open the Regional Settings control panel, set the correct

locale, then check the box that says "Set as System Default Locale" - this

will set the correct date formats for all system users (eg the

IUSR_<machinename> account) on the machine.



Also, you can avoid this problem on servers you don't control, by using the

yyyy/mm/dd format - not even the Americans are perverse enough to come up

with a yyyy/dd/mm format to break this.



Cheers

Ken



----- Original Message -----

From: "Wit B." <B.Wit@g...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Wednesday, December 20, 2000 9:36 PM

Subject: [asp_web_howto] date-functions





> Hello

>

> Recently I saw a few comments about several date-functions. A coworker has

a

> problem with sending dates to a SQL database. He converts the date using

> cdate(), but that sometimes doesn't work out. It puts 1 march 2000

> (01-03-2000) in as 3 january (03-01-2000) and so, but 15-12-2000 stays

that

> way.

>

> Does anyone know what to do or what function to use to get this right??

>

> Thanx already

>

> grt Bas Wit

>

> www.atosorigin.com







---

MaximumASP offers enhanced hosting solutions on the Windows 2000 platform. Dedicated processor, RAM, and server resources provide
dedicated server performance at virtual server prices. Commercial components provided; custom components allowed.

---

You are currently subscribed to asp_web_howto as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_web_howto-$subst('Recip.MemberIDChar')@p2p.wrox.com


  Return to Index