Combining Or Concating Seperate Fields For Date?

Dec 8, 2007

I have two tables in a SQL db.
Each has 3 separate fields used to store a date info:

lastservicemonth tinyint1
lastserviceday tinyint1
lastserviceyear smallint2
(and these fields can be nulls)

I want to compare the date info in Table A vs. Table B and find the latest date between the two.

I know I somehow need to combine the 3 separate fields in each table to form one date field. Then I can compare the dates.
But ths far I have been unsuccessful.

Any help would be greatly appreciated!

View 9 Replies


ADVERTISEMENT

Same Field From Several To Seperate Fields Of A Single Row

Nov 11, 2007

Hi,


I'm struggling with this. I'd like to perform a joined query
from two or more tables and take the same field from several
rows of one table into seperate fields of a single row in a new table.

Like this:



table 1

uidunameuloc
1mehere
1methere
2youhere
2 youthere


table 2

uidulocuparam#uparamval
1here1a
1here2b
1here3c
1there1d
1there2e
1there3f
2here1g
2here2h
2here3i
2there1j
2there2k
2there3l


result in table 3

uidunameuloc uparval1 uparval2 uparval3
1mehere a b c
1methere d e f
2youhere g h i
2 youthere j k l



uparam# field in table 2 always the same sequence


Any ideas????


Thanks...

View 2 Replies View Related

Displaying Two Fields In One Field When They Are Seperate Datatypes

Jan 16, 2008

Hi All.
I apologise if i have not posted this in the correct Topic before i start. But was uncertain where to post this query.
This is my first project in ASP.NET, MS Visual Web Developer 2005 Express and SQL Server 2005 Express. I have relatively little experience, so please bare with me. I have the table below:-
Column Name                 Data Type
OrderID                           intOrderNo                          intInvoiceNo                        varchar(50)PurchaseDate                 smalldatetimeCost                               moneyInsure                             money
I wish to have a dropdownlist on an aspx page display the OrderNo and the Cost e.g. 12345 £3.50. I have tried the SQL Statement below but that just calculates the addition of both.
SELECT OrderNo + ' ' + Cost AS Expr1
FROM [Order]
Do i have to convert them both to string/varchar first? If so, how?
Thanks for your replies.

View 3 Replies View Related

'Combining' Fields

Jul 12, 2006

Not concatenation, more... err.. I don't know what you'd call it.


SELECT
DISTINCT [C01241 Opened].[Col004] AS OpenerEmail,
[C01241 External Data].[DMCEMAIL] AS ExternalDataEmail,
[C01241 Internal Data].[Col15] AS InternalDataEmail
FROM [C01241 Opened]
LEFT JOIN [C01241 External Data] ON [C01241 External Data].[DMCEMAIL] = [C01241 Opened].[Col004]
LEFT JOIN [C01241 Internal Data] ON [C01241 Internal Data].[Col15] = [C01241 Opened].[Col004]


(Apologies for the table/col names, this is all very temporary)

So I've got a table, [C01241 Opened], which details all the people who registered. Those people might turn up in table [C01241 External Data], or they might turn up in [C01241 Internal Data]. Yes, they will always be in one or the other, and no, they won't appear in both.

At the moment, I just pull in the email address. But the client, of course, wants a whole bunch of fields that occur in the 'original data' tables: Firstname, Lastname, Company, Favourite color, etc.

What I want to know is if - and how - I can make the query output one column for each of the required fields, but populate it from either of the two 'original data' tables, depending on where their email address pops up in.

Does that make sense?

View 3 Replies View Related

Combining Two Fields Together

Apr 3, 2008

Hi,
I was wondering if there's a way to combine last, first and middle name together in one field instead of three different ones?

View 9 Replies View Related

Combining Fields

Mar 20, 2008

How do you combine ntext fields? I can combine nvarchar by this example: Position1 +', '+ Position2 AS Positions

Is there a way to combine ntext? Thanks!

View 1 Replies View Related

Combining Fields In A Select

Sep 19, 2005

I have:
Dim queryString As String = "SELECT distinct [CSULOG5].[status] + [CSULOG5].[lmca_nbr] FROM [CSULOG5]" I even tried & instead of +.
but it doesn't like it. Is it legit syntax for mssqlserver?
This is a vb project aspnet

View 7 Replies View Related

Combining Fields In A Stored Procedure

Apr 20, 2004

my question is this....I have to fields I want to retreive..One is a nvarchar and the other is an integer...I want to return them in this format
(interger field + '/' + nvarcharfield) as combinedfield
problem is i get errors when I try to get this value
I just need the info I know you cant add theses two together...

Example of output needed....

31/OfficeVisit

my sp

ALTER procedure EncounterCodes_NET
(
@ClinicID int
)
as
select
CombinedField=(EnCodeID + EnCodeDesc)
from
Clinic_Encodes
Where
ClinicID=@ClinicID
Order by Sortorder

View 1 Replies View Related

Easiest Way Of Combining Multiple Fields From Different Records Into One Record?

Jul 20, 2005

I have a table;CREATE TABLE theLiterals (theKey varchar (255) NOT NULL ,theValue varchar (255) NULL)INSERT INTO theLiterals VALUES('defaultServer','\MyServer')INSERT INTO theLiterals VALUES('defaultShare','MyShare')INSERT INTO theLiterals VALUES('defaultFolder','MyFolder')INSERT INTO theLiterals VALUES('defaultFile','MyFile.dat')I then try;SELECTdefaultServer = CASE WHEN theKey = 'defaultServer' THEN theValue END,defaultShare = CASE WHEN theKey = 'defaultShare' THEN theValue END,defaultFolder = CASE WHEN theKey = 'defaultFolder' THEN theValue END,defaultFile = CASE WHEN theKey = 'defaultFile' THEN theValue ENDFROM theLiteralsand I get;defaultServer defaultShare defaultFolder defaultFile\MyServer NULL NULL NULLNULL MyShare NULL NULLNULL NULL MyFolder NULLNULL NULL NULL MyFile.datbut I want it COALESCEd like this;defaultServer defaultShare defaultFolder defaultFile\MyServer MyShare MyFolder MyFile.dat....but my syntax is incorrect. Is there an efficient way of doing this.I want to have a script/UDF where I can say...GetLiteralsFor('defaultServer','defaultShare','def aultFolder','defaultFile')and then my one-row recordset will be...RS(0) will = '\MyServer'RS(1) will = 'MyShare'RS(2) will = 'MyFolder'RS(3) will = 'MyFile.dat'Thanks for any help!

View 5 Replies View Related

Update Fields With Searched First Date Record Fields

Jul 23, 2005

Hello !I'm trying to update one table field with another table searched firstdate record.getting some problem.If anyone have experience similar thing or have any idea about it,please guide.Sample case is given below.Thanks in adv.T.S.Negi--Sample caseDROP TABLE TEST1DROP TABLE TEST2CREATE TABLE TEST1(CUST_CD VARCHAR(10),BOOKING_DATE DATETIME,BOOKPHONE_NO VARCHAR(10))CREATE TABLE TEST2(CUST_CD VARCHAR(10),ENTRY_DATE DATETIME,FIRSTPHONE_NO VARCHAR(10))DELETE FROM TEST1INSERT INTO TEST1 VALUES('C1',GETDATE()+5,'11111111')INSERT INTO TEST1 VALUES('C1',GETDATE()+10,'22222222')INSERT INTO TEST1 VALUES('C1',GETDATE()+15,'44444444')INSERT INTO TEST1 VALUES('C1',GETDATE()+16,'33333333')DELETE FROM TEST2INSERT INTO TEST2 VALUES('C1',GETDATE(),'')INSERT INTO TEST2 VALUES('C1',GETDATE()+2,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+11,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+12,'')--SELECT * FROM TEST1--SELECT * FROM TEST2/*Sample dataTEST1CUST_CD BOOKING_DATE BOOKPHONE_NOC12005-04-08 21:46:47.78011111111C12005-04-13 21:46:47.78022222222C12005-04-18 21:46:47.78044444444C12005-04-19 21:46:47.78033333333TEST2CUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.800C12005-04-05 21:46:47.800C12005-04-14 21:46:47.800C12005-04-15 21:46:47.800DESIRED RESULTCUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.80011111111C12005-04-05 21:46:47.80011111111C12005-04-14 21:46:47.80044444444C12005-04-15 21:46:47.80044444444*/

View 3 Replies View Related

Combining Date And Time

Dec 22, 2005

I have 2 fields, one containing just the date and another containing the time. I want to combine them into a proper date/time format. No matter what I try, I lose 2 days in the process. Combining

2005-12-21 00:00:00.000
and
1899-12-30 14:30:00.000

will get me the 19th at 14:30. What am I missing here?

TIA

View 2 Replies View Related

Combining 2 Tables With Date Ranges

Jun 27, 2006

Hi there, I'm trying to generate a report for an old database and I'mhaving trouble coming up with an elegant way of going about it. Usingcursors and other 'ugly' tools I could get the job done but 1) I don'twant the report to take ages to run, 2) I'm not a big fan of cursors!Basically there are tables that track history and each table tends totrack only a specific value housed within a date range. I'm trying tocombine the tables to get a snap-shot of the complete history. I'mhaving problems dealing with the Start/End Dates from the two tablesand building the dates in the final table to be broken down by 'historytype'.Here are a few sample records and the results I'm trying to achieve:Table 1:CAgyHist (ProdID,AgyID,StartDate,EndDate)1 1 Jan 1, 2006 Jan 5, 20061 2 Jan 5, 2006 Jan 25, 20061 1 Jan 25, 2006 NULLTable 2:CInvHist (ProdID, InvID,StartDate,EndDate)1 1 Jan 1, 2006 Jan 23, 20061 2 Jan 23, 2006 Jan 15, 20061 1 Jan 15, 2006 NULLDesired End Result:CTotalHist (ProdID,AgyID,InvID,StartDate,EndDate)1 1 1 Jan 1, 2006 Jan 5, 20061 2 1 Jan 5, 2006 Jan 15, 20061 2 2 Jan 15, 2006 Jan 23, 20061 2 1 Jan 23, 2006 Jan 25, 20061 1 1 Jan 25, 2006 NULLMy challenge thus far has been dealing with the dates as they don'tnecessarily correspond - from one table to the other.I am by no means a database expert of any level and any help would begreatly appreciated.Thanks,Frank.

View 7 Replies View Related

Transact SQL :: Combining Parts Of 2 Dates Into Third Date

May 7, 2015

In a stored procedure I have 2 dates that I need to combine parts of into a third date. I need the year from date1 and the month/day from date2.

Date1 = '2015/6/1'
Date2 = '2016/1/1'
Date3 needs to be '2015/1/1'

I have been messing around with datepart and dateadd with no luck.

View 3 Replies View Related

Seperate Date And Time Merge; Done At SQL Update Or C# .NET Then Update

Feb 18, 2006

I do realize that his could be posted in a few spots but I think the answer is in the SQL.
I have a ASP.NET page, with a SqlDataSource, Text Box and Calendar Controls. I have the textbox and calendar controls eval'ed to the same sql data source DateTime Field. The text box is formatted eval to small time and the calendars eval has no formatting.
ex:
<asp:TextBox ID="START_TIME" Text='<%# Eval("EVENT_START","{0:t}") %>' runat=server Width=200></asp:TextBox>
I want to merge the two controls; one has the date the other has the time when I update the pages data to the SqlDataSource field EVENT_START. I've tried a couple of methods, but I would like some other opinions. As Sql server only supports date and time together I am storing the two together.
I could merge the two together in the code behind on the update button's event handler or merge the two during the update query using parameters.
Not that I could get an illegal date for the calendar control, but I could get garbage from the textfield time. So I still would have to do validation on the text field before the SQL server could do the update.
There's a few ways to go about this, so I was wondering if anyone else has figured out an elegant way to handle it.
wbochar

View 1 Replies View Related

Transact SQL :: Combining Dates To Group Into A Date Range?

Nov 17, 2015

My scenario is: a person has many events, all based on a date.  I need to aggregate the person to show min and max dates for a period, the period being defined as ending when there is not an event following the next date.

DECLARE @Events TABLE
(
PK_EventINTIDENTITY(1,1) PRIMARY KEY
,FK_UserINTNOT NULL
,EventDateDATENOT NULL
)
DECLARE @User TABLE

[Code] ....

I would expect the groups to look something like below:

Is this where a recursive CTE may be used?

View 6 Replies View Related

Find The Newest Date Of 2 Date Fields

Aug 20, 2007

I've 2 date fields clidlp,clidlc in my data base table. How do I find the newest dates between the fields? Thanks for your help!

View 1 Replies View Related

Fields Within A Certain Date

Mar 11, 2006

Hello.

I need an SQL Statement for SQL Server in VB.Net that will return values from a table for parts that are due for maintenance within 1 month.

Select * from Part Where DateNOverhaul <= '" & DateAdd(mm,-1,Date) & "' is not working.

I have been trying various solutions on the web and am getting confused because none seem to work. Please help me.

Thank you.

View 7 Replies View Related

SQL Date Fields ASP.NET

Jul 23, 2005

Hello !How to save on SQL server a date in this format?dd-mmm-yyyyAlso, I have a web form in ASP.net and I want the users to enter datesonly in the above format. I am going to need to make calculationsbeased on the above.Many Thanks,Marios Koumides

View 2 Replies View Related

Date Fields

Dec 18, 2007



Im creating a table that links employees to jobs, each employee can only be in one place at once. I have fields for start date and end date. Whats the best way of ensuring an employee cannot be assigned to more than one job at the same time.

Im thinking update/insert trigger that ensure Start Date or End Date being added is NOT >/=existing Start Date and </=existing End Date.

Anyone any better ideas?

Thanks in advance

Alex

View 3 Replies View Related

How Do You Sort On Two Date Fields ?

Nov 29, 2006

I am trying to order two date columns. One Ascending theother Descending. I am using the Orders table of Northwind in SQLServer. No idea why, but it only sorts on the first column I setcriteria on. I think you have to convert it to date as it gets storedas date/time...I triedSELECT     TOP 100 PERCENT OrderID, CustomerID, EmployeeID, OrderDate,CONVERT(char(10), RequiredDate, 103) AS RequiredDate,CONVERT(char(10),                     ShippedDate, 103) AS ShippedDate, ShipVia,Freight, ShipName, ShipAddress, ShipCity, ShipRegionFROM         dbo.OrdersORDER BY RequiredDate, ShippedDate DESCBut odd results occuredAny ideas appreciated

View 3 Replies View Related

Merging Date Fields In Sql

Feb 11, 2008

i have two columns in sql which is datetime datatype
fromdate & todate, now i want to display it like fromdate-todate in my front end
select fromdate +'-'+ todate as date from table.
when i use this query , the error is
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Thanks for any help

View 1 Replies View Related

Sorting Of Date Fields

Dec 27, 2004

hi,

When the autogenerate property of datagrid is set to true, how to perform sorting on date fields.

Example:

SELECT DC_NO AS [Document No],CONVERT(CHAR(10),DC_DT,103) AS [Document Date],
[Name] FROM XYZ

Here we convert the date field to the format "dd/mm/yyyy" so when sorting is done it is done in the format "dd/mm/yyyy". But instead sorting should be done in "yyyy/mm/dd" format.

View 6 Replies View Related

Please Help Me Populate My Date Fields

May 7, 2004

Hi,

I have the following table:

CREATE TABLE [Orders] (
[OrdID] [int] ,
[OrderDate] [datetime] ,
[OrderDateONLY] [datetime],
[OrderDayName] [nvarchar] (15),
[OrderMonth] [nvarchar] (25),
[OrderDayOfMonth] [smallint] NULL ,
[OrderWeekofYear] [smallint] NULL
)
GO

The field OrderDate contains BOTH Date and Time information. What I want to do is populate the fields (in bold above) from the OrderDate field... I have tried all that I could think of but nothing works. The last and the best try that I gave was the {B}following[/B] but that too does not work. Can you PLEASE help. Many thanks in advance:


Insert ORDERS
(OrderDateONLY, OrderDayName, OrderMonth, OrderDayOfMonth, OrderWeekofYear)
select
d, datename (dw, d), datename (mm, d), Year (d), datepart (ww, d)
from
(select convert (char (8), OrderDate, 112)as d
from ORDERS
) as x

View 3 Replies View Related

SQL- How To Compare Max Date Across Fields

Jan 4, 2006

Hello, I am wondering how to select the max date from a database view containing multiple date fields for a particular record. I am rusty at SQL and can't seem to get started. Here's an example of the data:

PRCL_IDPROJ_STRT_DTORD_DT ...
1242/3/20063/5/2006
5206/3/20068/2/2006
6412/31/2005
1872/14/20063/16/2006

I need to be able to compare the max date for each PRCL_ID record ("where prcl_id="). In the example above, prcl_id 124 has a max date of 3/5/2006, and prcl_id 520 has a max date of 8/2/2006, etc. The results of the SQL query should return the PRCL_ID and the max date.

Example query results:

PRCL_ID ORD_DT
124 3/5/2006

Please let me know if you can help or if I can provide more info.

Thanks,
Alexkav

View 6 Replies View Related

Comapring Date Fields

Feb 28, 2006

I am trying to compare two date fields; one is a string and one is a getdate() field. I am trying to get them into the same format so I can compare them. What am I doing wrong??? :eek:

select convert(integer, substring(loc_86, 1, 2)) as tmonth,
convert(integer, substring(loc_86, 3, 2)) as tday,
convert(integer, '20'+right(loc_86, 2)) as tyear,
datepart(month, (dateadd(day, -1, (getdate())))) as ymonth,
datepart(day, (dateadd(day, -1, (getdate())))) as yesterday,
datepart(year, (dateadd(day, -1, (getdate())))) as yyear
from ub_chg_tbl join ubmast_tbl
on (ubmast_tbl.patient_nbr = ub_chg_tbl.patient_nbr)
where tmonth = ymonth and tday = yesterday and ty= yyear

View 13 Replies View Related

Please Help Me Populate My Date Fields

May 7, 2004

Hi,

I have the following table:

CREATE TABLE [Orders] (
[OrdID] [int] ,
[OrderDate] [datetime] ,
[OrderDateONLY] [datetime],
[OrderDayName] [nvarchar] (15),
[OrderMonth] [nvarchar] (25),
[OrderDayOfMonth] [smallint] NULL ,
[OrderWeekofYear] [smallint] NULL
)
GO

The field OrderDate contains BOTH Date and Time information. What I want to do is populate the fields (in bold above) from the OrderDate field... I have tried all that I could think of but nothing works. The last and the best try that I gave was the following but that too does not work. Can you PLEASE help. Many thanks in advance:


Insert ORDERS
(OrderDateONLY, OrderDayName, OrderMonth, OrderDayOfMonth, OrderWeekofYear)
select
d, datename (dw, d), datename (mm, d), Year (d), datepart (ww, d)
from
(select convert (char (8), OrderDate, 112)as d
from ORDERS
) as x

View 7 Replies View Related

Nullable Date Fields ?

Dec 7, 2007

Is it bad design to allow nulls on a date field ? I can think of one case such as a sale of an item and populating a field for the date of purchase, only when the purchase took place (and null until then).

comments ?

View 5 Replies View Related

Date Only Fields In SQL Server

Jul 20, 2005

Does anyone know if Microsoft is planning to add a DATE only data typeto SQLServer.I know that you could use a datetime and convert/cast or use datepartto compare, but this can be tedious and error prone.What is the recommended way to compare date-only fields?eg if convert(char(11), @date_field) = convert(getdate(), @date_field)-- do something??

View 3 Replies View Related

Cumulating Fields By Date

Nov 18, 2007

Below is the schema and data for a simple table dat looks similar in structure to what I have.




Code Block
/****** Object: Table [dbo].[cumulative] Script Date: 11/17/2007 17:29:58 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cumulative]') AND type in (N'U'))
DROP TABLE [dbo].[cumulative]
GO
/****** Object: Table [dbo].[cumulative] Script Date: 11/17/2007 17:29:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cumulative]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[cumulative](
[PK] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ID] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[date] [datetime] NULL,
[wear] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[distance] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
)
END
GO
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'1', N'21', CAST(0x000098B200000000 AS DateTime), N'1', N'10')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'2', N'22', CAST(0x000098B200000000 AS DateTime), N'2', N'11')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'3', N'23', CAST(0x000098B200000000 AS DateTime), N'3', N'23')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'4', N'21', CAST(0x000098B300000000 AS DateTime), N'4', N'22')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'5', N'22', CAST(0x000098B300000000 AS DateTime), N'3', N'32')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'6', N'23', CAST(0x000098B300000000 AS DateTime), N'1', N'12')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'7', N'21', CAST(0x000098B400000000 AS DateTime), N'4', N'15')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'8', N'22', CAST(0x000098B400000000 AS DateTime), N'2', N'17')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'9', N'23', CAST(0x000098B400000000 AS DateTime), N'2', N'10')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'10', N'21', CAST(0x000098B500000000 AS DateTime), N'2', N'8')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'11', N'22', CAST(0x000098B500000000 AS DateTime), N'6', N'9')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'12', N'23', CAST(0x000098B500000000 AS DateTime), N'3', N'11')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'13', N'21', CAST(0x000098B600000000 AS DateTime), N'4', N'24')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'14', N'22', CAST(0x000098B600000000 AS DateTime), N'3', N'5')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'15', N'23', CAST(0x000098B600000000 AS DateTime), N'2', N'34')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'16', N'21', CAST(0x000098B700000000 AS DateTime), N'3', N'12')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'17', N'22', CAST(0x000098B700000000 AS DateTime), N'1', N'12')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'18', N'23', CAST(0x000098B700000000 AS DateTime), N'3', N'13')
INSERT [dbo].[cumulative] ([PK], [ID], [date], [wear], [distance]) VALUES (N'19', N'23', CAST(0x000098B800000000 AS DateTime), N'5', N'14')





I need a sql code that will calculate and create a cumulative wear and distance fields. Im working in SQL server 2005 (sp2).

What I will like to see for the new fields is like:






Cum_Dist
Cum_wear

10
1

11
2

23
3

32
5

43
5

35
4

47
9

60
7

45
6

55
11

69
13

56
9

79
15

74
16

90
11

91
18

86
17

103
14

117
19

Happy thanksgiving!!

View 15 Replies View Related

DTS - Clean Up Date Fields Upon Insertion

Feb 4, 2003

I am importing Visual FoxPro (6) views into SQL 2000 tables and I am looking for a snippet of code to "clean up" date fields upon insertion. I can insert the views into the SQL tables fine using the tables/views selection of DTS as my source. However, I would like to ensure the date fields are in fact vaild dates and not garbage using the SQL query option of DTS source. I would like to do the insert and cleanup in one step. Do you have a snippet of code to validate a date field that I can use? Thank you for any assistance in advance, Terry.

View 3 Replies View Related

BETWEEN With Date/Time In Separate Fields

Apr 22, 2008

My group is working on a project for school and neither of us have much experience with SQL or ASP. We are pretty much just writing an SQL query to get the data in a certain date range and using ASP to write the tables with the data in it.

Our problem is the SQL database has separate fields for date and time. There is nothing we can do about this because the VB.NET program that populates the tables automatically does this. We can't figure out how to do the BETWEEN statement when they are separate fields. We can do it for a date range and it works fine. An example of what we want to do is show the data from 11:00 am on 04/01/2008 until 4:00pm 04/03/2008.

Does anyone have any idea what we can do? I really want to learn this but it's frustrating because we can't seem to get much help at school.

View 5 Replies View Related

Creating A String From Date Fields

Jul 20, 2005

I have a table with a startdatetime and an enddatetime column such as:StartDateTime EndDateTime what I want to see returnedis:01/29/2004 10:30AM 01/29/2004 1:30PM "1/29/2004 10:30AM - 1:30PM"01/29/2004 10:30AM 01/30/2004 1:30PM "1/29/2004 10:30AM - 1/30/20041:30PM"01/29/2004 10:30AM 01/30/2004 10:30AM "1/29/2004 10:30AM - 1/30/200410:30AM"Maybe someone has accomplished this aready in a stored procedure andhas an example of how to do it?lq

View 2 Replies View Related

Importing Null Date Fields

Nov 27, 2006

I'm using SQL Server Express and am trying to import a CVS file. The CVS file contains a string field (named DAS) that represents a Date. This field can be null.

I've tried using the DTS Wizard to import this CVS file and convert the DAS field to a Date, which works great until it hits a record with a NULL DAS field. It then throws a convertion error.

Still using the DTS Wizard, I've changed the DataType of the DAS field in the Source file to [DT_DATE], it works fine but all the null dates are converted to 12/30/1899.

Is there a way (DTS Wizard or something else) that will allow me to import these CVS files with null Date fields and keep them as null in SQL Server table.

Thanks for any help,

Jon

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved