|
![](/images/resource/spacer.gif) |
|
Convert ตัวแปรจาก varchar เป็น Datetime เพื่อเทียบกับค่าใน DB |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (ASP)
date_split = Split(request.form ("month_fueling"),"/") ***month_fueling = 26/4/2555/25/5/2555
date_start = date_split(0)&date_split(1)&date_split(2) ***date_start = 26/4/2555
date_end = date_split(3)&date_split(4)&date_split(5) ***date_end=25/5/2555
ฟิลด์ที่เก็บค่า Datetime ไว้คือ invoice_date
Code (ASP)
sql = "SELECT liter, price_per_unit,cost,odometer,invoice_date FROM wshell_transaction WHERE invoice_date=convert(varchar,getdate(), 120) "
อยากนำค่า date_start และ date_end ไปเทียบกับค่าใน invoice_date อ่ะครับ
ไม่ทราบว่าต้อง Convert ตัวแปรจาก varchar ไปเป็น Datetime อย่างไรเหรอครับ
เพื่อให้สามารถหาข้อมูลระหว่างตัวแปร date_start และ date_end ได้
date_start,date_end (varchar as Variable)
invoice_date(Datetime in DB)
Tag : ASP, Ms SQL Server 2008, JavaScript, VBScript
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2012-04-19 11:30:58 |
By :
imperator |
View :
3651 |
Reply :
2 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ลองดูพวก CDate แล้วหรือยังครับ อันที่จริงแค่โยนค่าให้ถูก Format ก็ได้แล้วครับ แต่ผมจะใช้รูปแบบเช่น 19-Apr-2012 แบบนี้ไม่ต้องกลัว Format ผิดครับ ![](/images/bbcode/grin.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2012-04-19 11:46:19 |
By :
webmaster |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 01
|