Fix text-formatted numbers

Beside the suggestion from the following Microsoft page, re-assigning the value with Macro will also resolve.

Selection.Value = Selection.Value

http://office.microsoft.com/en-us/excel-help/fix-text-formatted-numbers-by-applying-a-number-format-HA102749043.aspx

Importing data from Excel is not easy. If the formatting of a column changed (the first 100 cells is number and the second 100 cells is text), the SSIS may convert the second 100 cells to NULL values. Cleaning the formats must be done before the import.

Determine Monday

In SQL Server, (Monday mod 7) = 0.

-- Microsoft SQL Server 2000
-- Determine Monday

SET DATEFIRST 7
PRINT @@DATEFIRST

-- Method One --------------------------------------------------
DECLARE @value AS INT

SET @value = FLOOR(CAST(GETDATE() AS FLOAT)) + 1
PRINT CAST(@value - (@value % 7) AS DATETIME)

 


-- Method Two --------------------------------------------------
DECLARE @today AS DATETIME
SET @today = GETDATE()
PRINT CAST( FLOOR(CAST(@today AS REAL)) - DATEPART(WEEKDAY, @today) + 2 AS DATETIME)

 


-- Method Three --------------------------------------------------
DECLARE @today AS DATETIME
SET @today = GETDATE()
PRINT CAST( DATEDIFF(DAY, -2, @today) - DATEPART(WEEKDAY, @today) AS DATETIME)

 


-- Method Four --------------------------------------------------

-- This one is not always work.
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE())/7*7, 0)


-- Method Five --------------------------------------------------
SET DATEFIRST 1
SELECT CAST(@date AS DATETIME) - DATEPART(WEEKDAY, CAST(@date AS DATETIME)) + 1

----------------------------------------------------------------
----------------------------------------------------------------

-- determine the first monday of the month
DECLARE @value AS INT
SET @value = FLOOR(CAST(GETDATE() - DATEPART(d, GETDATE()) AS FLOAT)) + 7
SELECT CAST(@value - (@value % 7) AS DATETIME)