sgadson
Posts: 45
|
Posted: 09/19/2004, 5:27 PM |
|
Hello,
I have a grid built with a custom sql statment. I would like to add creterior in the sql statment to pull all rows where the field Date is equal to the current date.
How is this done in CodeChargeStudio?
I know that you can use CurrentDate in the properties box as a Default value, but this does not work inside of a sql statment. I have also tried Date() and Now(). I get error messges stating that these are not recognized functions.
Can anybody help
_________________
Shawn |
|
|
rogersw
Posts: 16
|
Posted: 09/20/2004, 6:09 AM |
|
Hi Shawn
I did a Custom Insert last week where I needed to insert the current date and the userid into the database.
In the Data tab of the properties window for the page in question, you can define custom SQL. Here's an example
In the SQL box I put
insert into Project (name,userid, createdate)
values('{project}',{userid},'{thedate}')
Then in the Parameters dialog for this thedate I put
Name thedate DateTime.Now
Type Date Expression
Default Value 0
for userid I put
Name userid userid
Type Integer session
Default Value 0
Notice for Date type I needed the quotes but the Integer (session id) I did not.
The expression that returns the date is C# code. DateTime is in the System namespace.
Wayne Rogers
|
|
|
BlinkyBill
Posts: 86
|
Posted: 09/21/2004, 2:07 AM |
|
If you would like to insert the current date inside the SQL statement (assuming SQL Server here) this can be done. SQL Server doesn't have a Native Date() function, only GetDate() which returns current datetime. The standard way of getting the current date is to convert the GetDate() function to a CHAR(8) then convert is back to Datetime type:
select convert(datetime,convert(char(8), getdate(), 112))
returns:
2004-09-21 00:00:00.000
|
|
|
|