The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

I'm trying to do a query like this on a table with a DATETIME column.

SELECT * FROM table WHERE the_date = 2011-03-06T15:53:34.890-05:00

I have the following as an string input from an external source:

2011-03-06T15:53:34.890-05:00

I need to perform a query on my database table and extract the row which contains this same date. In my database it gets stored as a DATETIME and looks like the following:

2011-03-06 15:53:34.89

I can probably manipulate the outside input slightly ( like strip off the -5:00 ). But I can't figure out how to do a simple select with the datetime column.

I found the convert function, and style 123 seems to match my needs but I can't get it to work. Here is the link to reference about style 123

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks125.htm

asked 06 Mar '11, 21:07

henny%20penny's gravatar image

henny penny
11111
accept rate: 0%

edited 15 Mar '13, 17:16

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262

This site is very much SQLAnywhere orientated, you'll probably do better to ask the question on one of Sybase's Enterprise newsgroups - see http://www.sybase.com/detail?id=1012843

SQLA and ASE are completely different products.

(07 Mar '11, 11:36) Justin Willey
Comment Text Removed

Just to add: In SQL Anywhere, you could simply cast to a DATE type, i.e. "SELECT * FROM table WHERE the_date = CAST('2011-03-06 15:53:34.123456' AS DATE)"

(08 Mar '11, 08:09) Volker Barth
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×47
×46
×14
×6

question asked: 06 Mar '11, 21:07

question was seen: 9,475 times

last updated: 15 Mar '13, 17:16