|
I suspect that 2012-05-30 just might possibly be between the date_of_birth and the date_of_death (or some date in the future if null).
You are using DATE or DATETIME fields, right? Right?
modified 9-Jun-12 17:11pm.
|
|
|
|
|
|
SELECT * FROM Applicant
WHERE Date_Of_Death > CONVERT(VARCHAR,'30-05-2012',106)
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
Works great, if the guy is still alive today...
Your query selects all who have already died past that date - that's a difference.
|
|
|
|
|
Either date_fo_death is null or greater than the given date:
SELECT *
FROM Applicant
WHERE date_of_death is null
OR date_of_death>@somedate
|
|
|
|
|
SELECT
id_Applicant,
name,
date_of_birth,
date_of_death
FROM
Applicant
WHERE
'5/30/2012' BETWEEN date_of_birth AND ISNULL(date_of_death,'1/1/3000')
|
|
|
|
|
Just wondering what differences there are between these two connection methods in SSIS? We are connecting to SQL 2008 R2 databases.
Is one better performing than the other? Or is one easier to use? There does seem to be certain tasks that can only use one or the other.
|
|
|
|
|
An ADO.net connection will use the native client classes so it is better.
|
|
|
|
|
I am trying to insert string date to datetime column with the following way.(Sql2000)
CONVERT(DATETIME, @To, 103)
but this is not saving the DD/MM/YYYY format in the webserver, but it is working in my local machine.In the webserver sql it is saving as MM/DD/YYYY format.
|
|
|
|
|
Use a parameterized query, that will do the magic around the date format.
|
|
|
|
|
It is based on how the systems are setup. Cannot remember the SET command and have to go to work. Sorry.
|
|
|
|
|
SET DATEFORMAT DMY
that the one you were thinking of?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
|
Your string-representation is a culture-dependent format, a way of displaying a date in a specific culture. Date (and time) itself is not a string, but a number.
Make sure it's a DATE column in the database, and pass a Date (not a string ) to the query. Use parameters as suggested.
using (var con = new SqlConnection(connectionString))
using (var cmd = con.CreateCommand())
{
cmd.CommandText = "SELECT * FROM SomeTable WHERE MyDate = @MyDate";
cmd.Parameters.AddWithValue("@MyDate", DateTime.Now);
}
Bastard Programmer from Hell
|
|
|
|
|
the purpose of a database is to store information, not to format it. Store dates and datetimes in fields with the appropriate type, and let your applications take care of formatting when presenting results to the user. Do not try and have the database format stuff, you will get lots of trouble and never get satisfactory results.
And as others have said, use SQL parameters rather than SQL string concatenation, to feed dates and datetimes to the database; thus avoiding all conflicts with regional settings and the like.
|
|
|
|
|
If the column is a DATETIME, then the statement "it is saving as MM/DD/YYYY format" is untrue.
If the output of SELECT thedate FROM table shows different formats when executed on different systems, it is because of the "Region and Language" settings of the systems -- see the control panel -- and this is correct behaviour. If you want to override this behaviour (you shouldn't) then format it via the query.
And I strongly reccommend ISO 8601 format YYYY-MM-DD.
|
|
|
|
|
Put it like,
CONVERT( VARCHAR, @To AS DATETIME, 103 ) )
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
How to make a function in sql server-2008?
|
|
|
|
|
Have a read of this MSDN: Create Function[^]
there are some examples at the bottom of the page
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
CREATE FUNCTION 'functionname'
AS
--
--
--
- Happy Coding -
Vishal Vashishta
|
|
|
|
|
Table-Valued functions are awesome, like a view with input parameters. Like this:
CREATE FUNCTION [dbo].[Function_Name] (@inputParameter int) RETURNS table AS Return (<select clause> <from clause> WHERE <filterFieldName> = @inputParameter [<group by clause>])
Works in sql 2000+.
"Go forth into the source" - Neal Morse
|
|
|
|
|
Hi,
I want to send mails to the attendee of a particular event. So please tell me how can i send emails in c#.
Thanks..In advance
|
|
|
|
|
There's plenty of examples on the 'net showing how to send emails from C#.
How do I send mail using C#?[^]
Hope this helps getting you started
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
You can create a Window Service for same.
- Happy Coding -
Vishal Vashishta
|
|
|
|