Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2009, 03:15 AM
Authorized User
 
Join Date: Nov 2005
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
Default How to change a NVCHAr to a DATE

Hi,

I have in my SQL table a VAR where I save the date when a user enters.It is a NVARCHAR
Something like "26/06/2009 01:25:05"
But now I want to select only the dates that are bigger than a date. But the date in the table is a NVARCHAR and the one I use to check with is a real type of date. My code is
Code:
 
date_today=date()-1
date_today=date_today &"05:00:00"
sql="SELECT * from comercials where real_date >='"&date_today&"'"
So "real_date" is a NVCHAR and can not be checked as a DATEformat.

i tried several thing but my mind is getting fuzzy

Thx already!

Last edited by rtr1900; June 25th, 2009 at 03:37 AM..
 
Old June 25th, 2009, 06:28 AM
Authorized User
 
Join Date: Nov 2005
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi everyone,
afert a cup of coffee and surfing the net I found the solution to my problem.
here it is, in case anybody would come over the same problem.
I used the command CONVERT

CONVERT(DATETIME,date_real) >='"&date_new&"'

Date_real is the NVARCHAR and is converted to a datetime type.

Well I am happy again!!!!

Greetz
 
Old June 30th, 2009, 12:53 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Why not take the user input as a date from the very beginning?
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
CHANGE DATE FORMAT Vision G Access VBA 2 April 8th, 2008 12:16 PM
how to change date format prasannagps Forum and Wrox.com Feedback 2 September 14th, 2005 01:28 PM
need to change date format desprate Access VBA 1 April 10th, 2005 12:45 PM
Change date format Patrick19 Classic ASP Basics 1 March 14th, 2005 06:23 PM
date format change yuvalk SQL Server DTS 2 March 29th, 2004 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.