473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem in displaying and using date as criteria

3
Hello,
I have nvarchar field in SQL server 2000 database like yyyymmdd

I wanted to change it to datetime to use it in my criteria and separated to use it in three TextBoxes, one for dd, another one for mm and the last one for yyyy.

I used the convert function as below

SQL1 = SQL1 + " where convert(datetime,EMP_SENIORITY_DT_G) = '" + TextBox2.Text + "' ";

First I can't separate the date after conversion to three pieces dd/mm/yyyy.

second when I display the result of the sql it must be appear like 30/12/1964 , but instead of that it appeared like that yyyymmdd for example 19641230

Hope you can help me,
Thank you
May 22 '07 #1
3 1580
Plater
7,872 Expert 4TB
Hello,
I have nvarchar field in SQL server 2000 database like yyyymmdd

I wanted to change it to datetime to use it in my criteria and separated to use it in three TextBoxes, one for dd, another one for mm and the last one for yyyy.

I used the convert function as below

SQL1 = SQL1 + " where convert(datetime,EMP_SENIORITY_DT_G) = '" + TextBox2.Text + "' ";

First I can't separate the date after conversion to three pieces dd/mm/yyyy.

second when I display the result of the sql it must be appear like 30/12/1964 , but instead of that it appeared like that yyyymmdd for example 19641230

Hope you can help me,
Thank you
You have a nvarchar field with numbers in it like:
19641230
20070522

and you want to create a query where the result would be 30/12/1964 and 22/05/2007 ?

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2. ( SUBSTR(myfieldname,6,7) + '/' + SUBSTR(myfieldname,4,5) +SUBSTR(myfieldname,0,3) ) AS [DATE TIME]
  3.  
My substr numbers may be off, but you should be able to sperate them out like that.
May 22 '07 #2
I V
3
Thank you Plater, but I got this error

'SUBSTR' is not a recognized built-in function name !!
May 22 '07 #3
I V
3
Hi Plater

SUBSTRING worked great, thank you again
May 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sunil Korah | last post by:
Hi, My table contains a date field "DateOfVisit" and I have the following query SELECT Patients.PID, Patients.Lastname, Patients.FirstName, Patients.DateOfVisit, Patients.ToReport FROM...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
10
by: Ken | last post by:
I have a form, that when I open it, it shows all items that are due for inspection in the current month and that is overdue. This is shown in continuous view and it has a column that shows overdue...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
23
by: Steven TK | last post by:
Hi everyone, I wonder who can help me on the filter the Start Date and End Date. I still cannot manage to filter it. Eg. When the user click the StartDate(comboBox as 16/7/07), the Start...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
20
by: anthonyk | last post by:
Hi there, im hoping someone might be able to painlessly tell me what im incorrectly doing here/expecting. Im using Access 2007 I am creating a query to show ongoing tasks in a database. in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.