Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Include Current Date in SQL Statement

Posted on 2009-05-13
6
Medium Priority
?
473 Views
Last Modified: 2012-08-13
I have two sql statements that pull similar fields from different tables.
One sql statement just declares empty values so that it will have the same number of columns as another sql statement.
In one of my sql statements I return a date from the MSAccess database.
In the other sql statement I need to return the current date.
How would I do this?
Thank you
Below is the sql statement that I need to include the current date... See Date() as DateCreated.
 
        str = "SELECT 0 AS TaskCarsDetailID, TaskDetailsLU.TaskDetailsID, 0 AS Completed, " _
        & " TaskDetailsLU.TaskDetails, '""' AS TaskCarNotes, Date() AS DateCreated" _
        & " FROM TaskDetailsLU where TaskID = " & miTaskID & ""

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 18

Assisted Solution

by:carlnorrbom
carlnorrbom earned 1000 total points
ID: 24382265
Hi,
" & DateTime.Now.ToString() & "
should to the trick.
/Carl.
0
 

Author Comment

by:Sheritlw
ID: 24382271
I need just the date... What is it for that?
Thanks
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 24382273
Use Getdate() to return it.
  str = "SELECT 0 AS TaskCarsDetailID, TaskDetailsLU.TaskDetailsID, 0 AS Completed, " _
        & " TaskDetailsLU.TaskDetails, '""' AS TaskCarNotes, Getdate() AS DateCreated" _
        & " FROM TaskDetailsLU where TaskID = " & miTaskID & ""

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Assisted Solution

by:SNilsson
SNilsson earned 1000 total points
ID: 24382305
Or you can use now() as below
 str = "SELECT 0 AS TaskCarsDetailID, TaskDetailsLU.TaskDetailsID, 0 AS Completed, " _
        & " TaskDetailsLU.TaskDetails, '""' AS TaskCarNotes, '" & Now() & "' AS DateCreated" _
        & " FROM TaskDetailsLU where TaskID = " & miTaskID & ""

Open in new window

0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 24382356
Hi,
" & DateTime.Now.ToShortDateString() & "
0
 

Accepted Solution

by:
Sheritlw earned 0 total points
ID: 24382357
Since I am using MS Access, I need to use the correct syntax.
The solution is
#" & Today.Date() & "# AS DateCreated

Thanks for your help.  I will split the points between you.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question