Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> DateTime from SQL Server
 

Pages: 1
LLBLGen Pro Runtime Framework
DateTime from SQL Server
Page:1/1 

  Print all messages in this thread  
Poster Message
coderdude
User



Location:

Joined on:
24-Apr-2006 16:03:35
Posted:
10 posts
# Posted on: 12-May-2006 21:01:49.  
I've search the forums and can't seem to find a definate answer on this...

From my web app, I want to update a field called "DateUpdated" with the current date/time each time I update a row.

The "DateUpdated" column must be a user readable date/time.

I want to use the date/time from the SQL Server (i.e. GETDATE()) not from the web server (i.e. Date.Now)

I want to do so without making an extra call to SQL Server to retrieve the time.

I want to do so without the use of triggers.

Is this possible?
  Top
bclubb
User



Location:
Norman, Oklahoma
Joined on:
12-Feb-2004 22:18:04
Posted:
934 posts
# Posted on: 13-May-2006 02:58:36.  
Try setting the default value for the field to GETDATE() in sql server. Then once you save the field it will be refetched with the date.

  Top
coderdude
User



Location:

Joined on:
24-Apr-2006 16:03:35
Posted:
10 posts
# Posted on: 13-May-2006 23:31:41.  
I have done this, however, it will only populate the "DateUpdated" field in the table when the row is initially created. I would like the field in the table to be updated to the current date/time each time the row is updated.

Normally I would just add this to my SQL Update statement:

UPDATE Table
SET SomeField = @SomeValue, DateUpdated = GETDATE()
WHERE xxx
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14639 posts
# Posted on: 15-May-2006 14:58:36.  
Implement IExpression.

Please check the following thread for more details:
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3829


  Top
coderdude
User



Location:

Joined on:
24-Apr-2006 16:03:35
Posted:
10 posts
# Posted on: 15-May-2006 16:43:10.  
Thanks Walaa. This looks like it will do what I was searching for.
  Top
lubo278
User



Location:
Slovakia
Joined on:
10-Apr-2007 10:45:03
Posted:
32 posts
# Posted on: 06-Nov-2009 14:34:59.  
Sorry for hijacking thread:

I was just wondering. Is it possible to call this query?

Code:
SELECT GetDate()


I can only call

Code:
SELECT GetDate() FROM MyTable


but if ths MyTable is empty, it will return empty dataset.

Of course workaround would be stored procedure with only one line of code.


  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8150 posts
# Posted on: 06-Nov-2009 22:18:51.  
lubo278 wrote:
Sorry for hijacking thread:

The next time is better if you open a new thread.

lubo278 wrote:
I was just wondering. Is it possible to call this query?

Code:
SELECT GetDate()


I can only call

Code:
SELECT GetDate() FROM MyTable


but if ths MyTable is empty, it will return empty dataset.

Of course workaround would be stored procedure with only one line of code.

Indeed the SP is the best way to go. You also could execute raw sql: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=12293
David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.