Re: SQL



"TYE" <TYE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3379735F-A61E-46C5-92FD-EE8C1344DC1A@xxxxxxxxxxxxxxxx
hi,

i have a field that has the date of birth's in the following format,

20/06/1982

i want to take this out of the date of births / , the finish date of birth
field should be like this

20061982


You should store dates in a DATETIME column, not as formatted strings.
Assuming this column is a VARCHAR, first update the value to remove the
quotes:

UPDATE tbl
SET col = RIGHT(col,4)+SUBSTRING(col,4,2)+LEFT(col,2);

Now change it to DATETIME (or SMALLDATETIME):

ALTER TABLE tbl ALTER col DATETIME NOT NULL ;


i have a date and time field in sql how can i search one day only the
format
is the following

09/03/2005 23:42:33


DATETIME columns do not have a "format". A date is just a date. It is your
client application and not SQL Server that controls how the date is
displayed. Assuming that date is 2005-09-03, try:

SELECT *
FROM tbl
WHERE date_col >= '20050903'
AND date_col < '20050904' ;

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--


.



Relevant Pages

  • Re: SQL Server Date
    ... "Ibrahim Shameeque" wrote in message news:eoPECQxEEHA.3812@TK2MSFTNGP10.phx.gbl... ... > I know that SQL Server accepts date in the format yyyymmdd. ... I want> to know how to convert any US or UK date into the above format and then> insert it into the table's datetime column. ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL Server Date
    ... Or better yet, format the date in an unambiguous style on the client, before ... "Ibrahim Shameeque" ... > I know that SQL Server accepts date in the format yyyymmdd. ... > insert it into the table's datetime column. ...
    (microsoft.public.sqlserver.programming)
  • SQL Server Date
    ... I know that SQL Server accepts date in the format yyyymmdd. ... insert it into the table's datetime column. ... Ibrahim Shameeque ...
    (microsoft.public.sqlserver.programming)
  • Re: mm/dd/yyyy format question
    ... I was not talking about how .Net or SQL Server stores date/time values ... I get the impression that you are talking about ISO 8601 in terms ... applications use the format for unambiguously representing date/time ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Querying on dates in dd/mm/yyyy hh/mm/ss format using Access2002 And SQL Server 7
    ... For parsing a string to a date/time, the 103 format doesn't limits the user ... > which is used as the row source for the results form). ... > other solutions assuming I have to use SQL Server 7? ... > I don't understand how I can use parameterized stored procedures to solve ...
    (microsoft.public.access.adp.sqlserver)