CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Current Date with Custom SQL

Print topic Send  topic

Author Message
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 :-)
View profile  Send private message
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



View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.