| Author |
Topic |
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-23 : 02:43:37
|
| Hi all of you,iam having two problems related to date issues that i want to do in Stored procedure.1) iam having one input text field, i want to do that user should enter the date in mm/dd format.if user enter date in like thatt 1/5 then it append 0 before month and date i.e 01/05.2)another issue is that in which i want to do that if user enter date 04/05/2004, then it will display on the same field as April 5, 2004.plz help me regarding above two issues.thanksAbhi |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-23 : 02:49:51
|
| 1) can be done easily using charindex(), substring()2) you can done using convert()Check out Books OnLine for detail usage of the above funtions-----------------'KH'I don't do homework |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-23 : 03:23:10
|
| Where do you want to show the converted dates?Use Front End Application to format the date in the format you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-23 : 23:27:00
|
| hello all of u and khtanthanks for the reply..iam still facing problem in second issue, i have tried to used convert function to try to resolve it, but did not get it.can plz u let me know, how to do that.thanksabhi |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-23 : 23:38:36
|
| [code]declare @strdt varchar(50)select @strdt = '04/05/2004'select convert(varchar(11), convert(datetime, @strdt), 100)[/code]----------------------------------'KH'I do work from home but I don't do homework |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-24 : 00:04:13
|
| Which Front End application are you using?MadhivananFailing to plan is Planning to fail |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-24 : 04:40:25
|
| thanx Khtan..but iam having field type mm/dd..means user enter like 05/04 and display the result as May 4,thanksabhi |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-24 : 04:50:16
|
| Which Front End application are you using?Post the table structureMadhivananFailing to plan is Planning to fail |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-24 : 05:35:37
|
| hello iam using xml, javascript for the validation of mm/dd format.but in backend, i also want to update in sql server using stored procedure.so i need help in Stored procedure for the mm/dd format.if i enter 05/04, then display may, 4.help methanksabhi |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-24 : 05:37:15
|
my date format is mm/dd abd display accordingly.plz helpthanksabhiquote: Originally posted by khtan
declare @strdt varchar(50)select @strdt = '04/05/2004'select convert(varchar(11), convert(datetime, @strdt), 100) ----------------------------------'KH'I do work from home but I don't do homework
|
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-25 : 03:40:00
|
| plzzzz help meee |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-25 : 04:00:19
|
see these code declare @strdt varchar(50)select @strdt = '04/05/2004'select convert(varchar(11), convert(datetime, @strdt, 101), 100), convert(varchar(11), convert(datetime, @strdt, 103), 100) ----------------------------------'KH'Happy Chinese New Year |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-25 : 06:01:03
|
| thanx khtan..but my prob doesnot get solved..i want to display only April 5...i doesnot want to display year.. i.e 2005plz helpabhi |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-25 : 06:07:54
|
Use LEFT()declare @strdt varchar(50)select @strdt = '04/05/2004'select left(convert(varchar(11), convert(datetime, @strdt, 101), 100), 6), left(convert(varchar(11), convert(datetime, @strdt, 103), 100), 6) ----------------------------------'KH'Happy Chinese New Year |
 |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-01-25 : 06:10:09
|
| use this append a default year if user is just inputting mm/dddeclare @strdt varchar(50)select @strdt = '04/15' +'/1900'select convert(varchar(7), convert(datetime, @strdt,101), 100) |
 |
|
|
abhi143
Starting Member
32 Posts |
Posted - 2006-01-31 : 04:48:02
|
| thanks all of u...thanks shallu and khtaniam getting month Apr, i need full month name i.e April..plz helpabhi |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-31 : 05:28:24
|
| It should be Front End workdeclare @strdt varchar(50)select @strdt = '04/15' +'/1900'select Datename(month,convert(datetime, @strdt,101))+' '+cast(day(convert(datetime, @strdt,101)) as varchar) as Converted_dateMadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-31 : 06:37:57
|
| Agreed. It should be done at the front end. If you are doing it on the SQL Server side, the format will be fixed in the queries. If this is performed on the front end, it can be sensitive to the Control Panel's Date & Time settings----------------------------------'KH' |
 |
|
|
|