Re: SQL question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Guy Cohen wrote:
Hi all
I use ASP.NET with MS SQL Server Express 2005.

How do I:
1. Select a date in a specific format:
e.g. select FORMAT(recorddate,'DD/MM/YY') from mytable
2. Select only last 4 characters from a string.
e.g. select right(creditcardnumber,4 ) from mytable

Both return error........

TIA
Guy

Look up the following functions in the Online help:

DATEPART
SUBSTRING

For the date, you can issue this command before executing the SELECT:

SET DATEFORMAT dmy

--

Riki


.



Relevant Pages

  • 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: Help needed in BCP and Bulk Insert
    ... format, so if you use a text file, everything has to be converted to ... Bulk load: An unexpected end of file was encountered in the data file. ... SELECT @keepdate = '20100101' ... You would run this job from SQL Server Agent, ...
    (microsoft.public.sqlserver.programming)
  • 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)
  • Re: Moving a VBA function to SQL server
    ... "String Functions " in Books Online. ... The SQL server database contains a table named 'WorkOrders'. ... This will produce a job header formatted like this: ... The format he specifies is stored in table 'Settings' - field 'JobHdrMask' ...
    (comp.databases.ms-access)
  • Re: unicode textbox problem
    ... I get the data in the above format from SQL server. ... If I move the same data into an asp:textbox, or an html input textbox, I ... But I need this to show the Chinese characters. ...
    (microsoft.public.dotnet.languages.csharp)