473,326 Members | 2,023 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,326 software developers and data experts.

Date format in DropDown

Hi,

I have a Drop Down List that is being populated by a sql server database with the following query...

sqlSchedule = ("SELECT cast(DATE_FROM as smalldatetime) AS DATE from EVENTS WHERE ITEMID = '" + txtid + "'");

The DropDown is populated with '30/09/2007 12:00:00 AM'

Can someone please tell me how to change the date format in the dropdown to 30/09/2007.

SqlCommand = new SqlCommand(sqlSchedule);
SqlCommand.Connection = SqlConnection;
dataSeta = new DataSet();
SqlDataAdapter = new SqlDataAdapter();
SqlDataAdapter.SelectCommand = SqlCommand;

SqlDataAdapter.Fill(dataSeta, "TableA");

cboCourseDates.DataSource = dataSeta;

cboCourseDates.DataTextField = "DATE";
cboCourseDates.DataValueField = "DATE";
cboCourseDates.DataBind();

Thanks,

Natalie.
Sep 23 '07 #1
3 1831
Shashi Sadasivan
1,435 Expert 1GB
Hi,

I have a Drop Down List that is being populated by a sql server database with the following query...

sqlSchedule = ("SELECT cast(DATE_FROM as smalldatetime) AS DATE from EVENTS WHERE ITEMID = '" + txtid + "'");

The DropDown is populated with '30/09/2007 12:00:00 AM'

Can someone please tell me how to change the date format in the dropdown to 30/09/2007.

SqlCommand = new SqlCommand(sqlSchedule);
SqlCommand.Connection = SqlConnection;
dataSeta = new DataSet();
SqlDataAdapter = new SqlDataAdapter();
SqlDataAdapter.SelectCommand = SqlCommand;

SqlDataAdapter.Fill(dataSeta, "TableA");

cboCourseDates.DataSource = dataSeta;

cboCourseDates.DataTextField = "DATE";
cboCourseDates.DataValueField = "DATE";
cboCourseDates.DataBind();

Thanks,

Natalie.
If you are usinf sql server as your DB.
then you can modify your sql statment from
Expand|Select|Wrap|Line Numbers
  1. SELECT cast(DATE_FROM as smalldatetime) AS DATE 
to
Expand|Select|Wrap|Line Numbers
  1. SELECT date(DATE_FROM) AS DATE 
cheers!
Sep 23 '07 #2
krris
10
hi
try This

Select convert(varchar(12),DateField,Number) from .....

Number should be like 101,102,103,106 try this number indicate the Date format like dd/MM/yyyy,dd-MM-yy, etc
Sep 24 '07 #3
Plater
7,872 Expert 4TB
Yes, use the Convert() function.

For a table on what values to pass to format the date:
http://msdn2.microsoft.com/en-us/library/ms187928.aspx
Sep 24 '07 #4

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

Similar topics

10
by: Bob Bedford | last post by:
I've two input fields in wich the user enter dates. I've put something like "enter date here (dd/mm/yyyy) but most of the user don't enter date in correct format. So I'd like to be able to get...
2
by: Astra | last post by:
Hi Guys Can anybody advise me on how to check for a 'no later than today's date' value from 3 <SELECT> fields. I have 3 <SELECT> fields, which are one for the day, one for the month and one...
4
by: James W. Hall Sr. | last post by:
I am filling a dropdown listbox in ASP.NET. The display value is a date field from SQL Server. When I bind the data to the dropdown listbox the time appears in with the data (12:00 am). In the...
4
by: mark | r | last post by:
Im haing issues with dates, theyre swapping between us and uk formats so things are being displayed as the 1st jan or 5th may (01.05 or 05.01) theres no logic to it, and its totally random...
7
by: XmlAdoNewbie | last post by:
Hi All, I am wondering if it is possible to allow nulls or empty strings when it comes to the datetimepicker control. I have an app with a few datetimepickers on it and there are some instances...
2
by: amrita | last post by:
hi i have a dropdown where i have put dates in mm/dd/yy format and want to filter the date from the database(format mm/dd/yy time) based on these dates ie if i select 01/06/02 from the dropdown ,it...
0
by: Ed Bick | last post by:
Well, I read today about how I could set the dropdown value to False to change the control from presenting a Calendar to cycling through the times. Before getting that, I developed a custom Time...
8
by: Bostonasian | last post by:
I don't even know where to begin this as hierarchy is always confusing to construct dynamically in any form(query, xslt,etc). However it is very easy to follow when it's presented. I've done...
2
by: Claes Wedin | last post by:
My customer needs a DateTimePicker in VS2005 C# that can show emty date values (blank/space/null). I need a control that: 1. Can show a blank value 2. Detete a date when hitting the delete...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.