| Author |
Topic |
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 10:13:49
|
Hello,I want to insert a date to a table.However the date should be as of today.Not sure off hand the query.The code looks like below INSERT INTO EMPLOYEE_GROUP ([EMP_ID], [GRP_ID], [STR_ID], [EXP_DATE]) SELECT '1234', 'Cashier', ACTL_STR_ID, 'a date' from ARTS Where EXP_DATE>getdate() Thanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-30 : 10:28:35
|
What data type ist EXP_DATE?Show example value for EXP_DATE please.Explain exactly the daterange that is to insert into destination table from source table please.Fred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 10:43:50
|
| datetime type6/30/2009 12:00:00 AMThe validated date is from tomorrow to the future.I mean we can't select the day before today. |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-06-30 : 11:28:22
|
| valid date is anything after tomorrow, and you cannot select day before today, so what about today? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-30 : 11:31:47
|
[code]Where EXP_DATE> dateadd(day, datediff(day, 0, getdate()), 0)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 11:36:09
|
| Today is okay. |
 |
|
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 12:01:56
|
| Invalid column name 'EXP_DATE'INSERT INTO EMPLOYEE_GROUP ([EMP_ID], [GRP_ID], [STR_ID], [EXP_DATE]) SELECT '1234', 'Cashier', ACTL_STR_ID, '06/25/2009' from ARTS Where [EXP_DATE]>dateadd(day, datediff(day, 0, getdate()), 0) |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-06-30 : 12:03:26
|
| check your arts table, use whatever date you want to use. |
 |
|
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 12:12:14
|
| There is no EXP_DATE column in the table ARTS.I only want to get ACT_STR_ID from ARTS. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-30 : 12:31:22
|
[code]INSERT INTO EMPLOYEE_GROUP ([EMP_ID], [GRP_ID], [STR_ID], [EXP_DATE])SELECT '1234', 'Cashier', ACTL_STR_ID, dateadd(day, datediff(day, 0, getdate()), 0)from ARTS Where EXP_DATE>getdate()[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
zhshqzyc
Posting Yak Master
240 Posts |
Posted - 2009-06-30 : 13:31:20
|
| Well, the application is very complex.The EXP_DATE actually is imported from outside as a variable.The purpose is to disallow to select the day before today.I hope the sql code likeINSERT INTO EMPLOYEE_GROUP ([EMP_ID], [GRP_ID], [STR_ID], [EXP_DATE])SELECT '1234', 'Cashier', ACTL_STR_ID, @tempDate from ARTS where someday_after_today_condition |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-30 : 13:33:38
|
| [code]INSERT INTO EMPLOYEE_GROUP ([EMP_ID], [GRP_ID], [STR_ID], [EXP_DATE])SELECT '1234', 'Cashier', ACTL_STR_ID, @tempDate from ARTS where @tempDate>= dateadd(dd,datediff(dd,0,getdate()),1)[/code] |
 |
|
|
|